{
	let num_lines = ref 0
	let num_chars = ref 0

    open Printf
    open Parser
	open Functions
    	
let op x = match x with
  | "+" -> PLUS
  | "-" -> MINUS
  | "." -> BINARY1 x
  | "new" -> UNARY2 x
  | "!" | "~" | "++" | "--" | "typeof" | "void" | "delete" -> UNARY3 x
  | "*" | "/" -> BINARY4 x
  | "<<" | ">>" | ">>>" -> BINARY5 x
  | "<" | "<=" | ">" | ">=" | "in" | "instanceof" -> BINARY6 x
  | "==" | "!=" | "===" | "!==" -> BINARY7 x
  | "&" | "^" | "|" -> BINARY8 x
  | "&&" -> BINARY9 x
  | "||" -> BINARY10 x
  | "=" | "+=" | "-=" | "*=" | "/=" | "%=" | "<<=" | ">>=" | ">>>=" | "&=" | "^=" | "|=" -> ASSIGN_OP x
  | x -> BINARY10 x

}

let ident =  ['a'-'z' 'A'-'Z' '_' '$'] ['a'-'z' 'A'-'Z' '0'-'9' '_' '$']*
let number = ['0'-'9']+
let operator = ['~' '!' '%' '^' '&' '+' '-' '*' '/' '=' '|' '>' '<']+ | "new" | "typeof" | "void" | "delete" | "instanceof"

rule main = parse

  | "//" [^ '\n']* '\n'		{ main lexbuf }
  |  [ '\n' ' ' '\t' ] 		{ main lexbuf }

  | number as x				{ NUMBER x }
  | operator as x 			{ op x }
  
  | "var" 		{ VAR }
  | "function" 	{ FUNCTION }
  | "return" 	{ RETURN }
  | "select" 	{ SELECT }
  | "from" 		{ FROM }
  | "join" 		{ JOIN }
  | "where" 	{ WHERE }
  | "natural" 	{ NATURAL }
  | "left" 		{ LEFT }
  | "right" 	{ RIGHT }
  | "inner" 	{ INNER }
  | "cross" 	{ CROSS }
  | "outer" 	{ OUTER }
  | "as" 		{ AS }

  | ident as x	{ ID x }

  | '('			{ LP }
  | ')'			{ RP }
  | '['			{ LBRACKET }
  | ']'			{ RBRACKET }
  | '{'			{ LBRACE }
  | '}'			{ RBRACE }
  | ':'			{ COLON }
  | ';'			{ SEMI }
  | ','			{ COMMA }

  | eof         { EOF }

